//
//  VCSettingViewController.m
//  VideoCollage
//
//  Created by Mac on 2018/6/27.
//  Copyright © 2018年 stoneobs.qq.com. All rights reserved.
//

#import "VCSettingViewController.h"
#import "STMonitorHomeViewController.h"
@interface VCSettingViewController ()
@property(nonatomic, strong) NSArray                     *dataSouce;/**< <##> */
@end

@implementation VCSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"Settings";
    [self configSubView];
    [self configDataSouce];
    // Do any additional setup after loading the view.
}

#pragma mark --subView
- (void)configSubView{
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 150)];
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 60, 60)];
    imageView.layer.cornerRadius = 6;
    imageView.clipsToBounds = YES;
    imageView.image = [UIImage imageNamed:@"icon"];
    [header addSubview:imageView];
    imageView.centerX = UIScreenWidth/2;
    imageView.centerY = header.height/2;
    self.tableView.tableHeaderView = header;
    
    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoDebugMode)];
    imageView.userInteractionEnabled = YES;
    tap.numberOfTapsRequired = 5;
    [imageView addGestureRecognizer:tap];
}
- (void)configDataSouce{
    
    NSArray * section = @[
                          [[STTableEasyModel alloc] initWithTextString:@"Contact" imageName:@"contact"],
                          [[STTableEasyModel alloc] initWithTextString:@"About Us" imageName:@"aboutus"],
                          [[STTableEasyModel alloc] initWithTextString:@"User Terms" imageName:@"user"],
                          [[STTableEasyModel alloc] initWithTextString:@"Privacy Policy" imageName:@"privacy"],
                          ];
    NSArray * sectionTwo = @[
                          [[STTableEasyModel alloc] initWithTextString:@"Restore" imageName:@"restore"]
                          ];
    self.dataSouce = @[
                       section,
                       sectionTwo
                       ];
    [self.tableView reloadData];
}
#pragma --mark UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return self.dataSouce.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return [self.dataSouce[section] count];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 50;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return 0.01;
    }
    return 11;
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [UIView new];
}
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [UIView new];
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * reuseIdentifier =  @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier];
        
    }
    cell.textLabel.textColor = UIColorFromRGBA(0x333333);
    cell.textLabel.font = [UIFont systemFontOfSize:14];
    cell.detailTextLabel.font = [UIFont systemFontOfSize:13];
    cell.detailTextLabel.textColor =FlatOrange;
    
    STTableEasyModel * model = self.dataSouce[indexPath.section][indexPath.row];
    [cell setSt_tableEasyModel:model];
    cell.textLabel.textColor =FlatOrange;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}
#pragma --mark UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}
- (void)gotoDebugMode{
    UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:STMonitorHomeViewController.new];
    [self presentViewController:nav animated:YES completion:nil];
}
@end
